from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
# 打开浏览器
driver = webdriver.Chrome()
driver.get('https://www.kugou.com/')
sleep(2)
# 窗口最大化
driver.maximize_window()
sleep(2)
# 点击登录
# driver.find_element(By.CLASS_NAME, 'cmhead1_d5 _login').click()
driver.find_element(By.XPATH, '/html/body/div[1]/div[1]/div/div[2]/div[2]/div[1]').click()
sleep(3)
# ***
# #强制等待10 点击手机号登录
# sleep(10)
# # 进入frame框架
# # f = driver.find_element(By.XPATH, '/html/body/div[8]/iframe')
# f = driver.find_element(By.XPATH, '//*[@id="loginIframe"]')
# driver.switch_to.frame(f)
# sleep(2)
# ***

# 进入frame框架
f = driver.find_element(By.XPATH, '//*[@id="loginIframe"]')
driver.switch_to.frame(f)
sleep(3)
# 点击手机号登录
driver.find_element(By.ID, 'j_kg_popup_switch').click()
sleep(3)
# 输入手机号
driver.find_element(By.ID, 'KgPopupPhone').send_keys('15985645480')
# 强制等待，输入验证码
sleep(20)
driver.find_element(By.CLASS_NAME, 'kg_popup_login_btn').click()
sleep(10)
